#include "Variable.h"
#include "../Exceptions.h"
#include "../GeneralVisitor.h"

Variable::Variable(string iName)
{
    fVarName = iName;
}

void Variable::CheckVariables(set<string>& oVariables, string iParentName)
{
    if(oVariables.find(fVarName) == oVariables.end())
        throw VariableNotDeclaredException(iParentName, fVarName);
}

ExpressionType* Variable::GetType(map<string, ExpressionType*> &iVarTypes, string iParentName)
{
    if(iVarTypes.find(fVarName) != iVarTypes.end())
        return iVarTypes[fVarName]->Clone();

    // wot? promenna tam neni? coze?
    throw VariableNotDeclaredException(iParentName, fVarName);
}

void Variable::Accept(GeneralVisitor* iVisitor)
{
    iVisitor->Visit(this);
}
